//
//  LSLeagueDetailCell.m
//  LookScore
//
//  Created by wr on 2018/4/17.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSLeagueDetailCell.h"



#pragma mark 🔥 LSLeagueDetailCell
@interface LSLeagueDetailCell()
@property (nonatomic, strong) NSMutableArray *lableArray;
@property (nonatomic, strong) UIImageView *logoImage;
@end
@implementation LSLeagueDetailCell


+(LSLeagueDetailCell *)TableCellByTableView:(UITableView *)tableView{
    LSLeagueDetailCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSLeagueDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }return cell;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
    CGFloat width=(LSScreenWidth-95)/6;
    UILabel *lable;
    for (int i=0; i<7; i++) {
        lable=[UILabel new];
        lable.textColor = LSTitleGrayColor2;
        lable.font=LSFontSize12;
        lable.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:lable];
        [self.lableArray addObject:lable];
        if (i==0) {
            lable.textColor = LSTitleGrayColor3; lable.sd_layout.leftEqualToView(self.contentView).centerYEqualToView(self.contentView).widthIs(width).heightIs(30);
        }else if (i==1){
            self.logoImage = [[UIImageView alloc] init];
            [self.contentView addSubview:self.logoImage];
            self.logoImage.sd_layout.leftEqualToView(self.contentView).offset(width).centerYEqualToView(self.contentView).widthIs(20).heightIs(20);
            
            lable.sd_layout.leftSpaceToView(self.logoImage, 0).centerYEqualToView(self.contentView).widthIs(80).heightIs(30);
            lable.textAlignment = NSTextAlignmentCenter;
            
        }else{
            if (i==6) {
                lable.textColor = LSTitleGrayColor1;
            }
            lable.sd_layout.leftEqualToView(self.contentView).offset(width+95+(i-2)*width).centerYEqualToView(self.contentView).widthIs(width).heightIs(30);
            
        }
        
    }
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = LSLineGrayColor;
    [self.contentView addSubview:lineView];
    lineView.sd_layout.leftEqualToView(self.contentView).bottomEqualToView(self.contentView).rightEqualToView(self.contentView).heightIs(0.5);
}

- (void)setModel:(LSLeagueTableModel *)model{
    _model = model;
//    self.logoImage sd_setImageWithURL:model.
    NSArray *array = @[model.IntegralRank,model.TeamName,model.TeamCountScreenings,[NSString stringWithFormat:@"%@/%@/%@",model.TeamWinScreenings,model.TeamFlatScreenings,model.TeamLossScreenings],[NSString stringWithFormat:@"%@/%@",model.TeamGet,model.TeamLose],model.TeamClean,model.TeamIntegralNum];
    [self.lableArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *lable = (UILabel *)obj;
        lable.text = array[idx];
    }];
    
    
    [self.logoImage sd_setImageWithURL:[NSURL URLWithString:TeamImageHeaderUrl((long)model.TeamId)] placeholderImage:nil];
}
- (NSMutableArray *)lableArray{
    if (!_lableArray) {
        _lableArray = [NSMutableArray array];
        
    }
    return _lableArray;
}
@end


#pragma mark 🔥 LSLeagueDetailCell
@interface LSLeagueHandicapCell()
@property (nonatomic, strong) NSMutableArray *lableArray;
@property (nonatomic, strong) UIImageView *logoImage;
@end
@implementation LSLeagueHandicapCell


+(LSLeagueHandicapCell *)HandicapCellByTableView:(UITableView *)tableView{
    LSLeagueHandicapCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSLeagueHandicapCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }return cell;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
//    NSArray *titleArray = @[@"16",@"莫斯科火车头",@"9",@"6",@"2",@"1",@"60",@"20",@"10"];
    CGFloat width=(LSScreenWidth-95)/8;
    UILabel *lable;
    for (int i=0; i<9; i++) {
        lable=[UILabel new];
//        lable.text = titleArray[i];
        lable.textColor = LSTitleGrayColor1;
        lable.font=LSFontSize12;
        lable.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:lable];
        [self.lableArray addObject:lable];
        if (i==0) {
            lable.textColor = LSTitleGrayColor3; lable.sd_layout.leftEqualToView(self.contentView).centerYEqualToView(self.contentView).widthIs(width).heightIs(30);
        }else if (i==1){
            self.logoImage = [[UIImageView alloc] init];
            [self.contentView addSubview:self.logoImage];
            self.logoImage.sd_layout.leftEqualToView(self.contentView).offset(width).centerYEqualToView(self.contentView).widthIs(20).heightIs(20);
            
            
            lable.sd_layout.leftSpaceToView(self.logoImage, 0).centerYEqualToView(self.contentView).widthIs(80).heightIs(30);
            lable.textAlignment = NSTextAlignmentCenter;
            
        }else{
            lable.sd_layout.leftEqualToView(self.contentView).offset(width+95+(i-2)*width).centerYEqualToView(self.contentView).widthIs(width).heightIs(30);
        }
    }
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = LSLineGrayColor;
    [self.contentView addSubview:lineView];
    lineView.sd_layout.leftEqualToView(self.contentView).bottomEqualToView(self.contentView).rightEqualToView(self.contentView).heightIs(0.5);
}
- (void)setModel:(LSLeagueHandicapModel *)model{
    _model = model;
    NSArray *array = @[model.ranking,model.TeamName,model.MatchTotol,model.WinTotol,model.FlatTotol,model.LoseTotol,model.WinProbability,model.FlatProbability,model.LoseProbability];
    [self.lableArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *lable = (UILabel *)obj;
        lable.text = array[idx];
    }];
    [self.logoImage sd_setImageWithURL:[NSURL URLWithString:TeamImageHeaderUrl((long)model.TeamId)] placeholderImage:nil];
}
- (NSMutableArray *)lableArray{
    if (!_lableArray) {
        _lableArray = [NSMutableArray array];
        
    }
    return _lableArray;
}
@end



#pragma mark 🔥 LSLeagueSizeplateCell
@interface LSLeagueSizeplateCell()
@property (nonatomic, strong) NSMutableArray *lableArray;
@property (nonatomic, strong) UIImageView *logoImage;
@end
@implementation LSLeagueSizeplateCell


+(LSLeagueSizeplateCell *)SizeplateCellByTableView:(UITableView *)tableView{
    LSLeagueSizeplateCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSLeagueSizeplateCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }return cell;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
//    NSArray *titleArray = @[@"16",@"莫斯科火车头",@"9",@"6",@"2",@"1",@"60",@"20",@"10"];
    CGFloat width=(LSScreenWidth-95)/8;
    UILabel *lable;
    for (int i=0; i<9; i++) {
        lable=[UILabel new];
//        lable.text = titleArray[i];
        lable.textColor = LSTitleGrayColor1;
        lable.font=LSFontSize12;
        lable.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:lable];
        [self.lableArray addObject:lable];
        if (i==0) {
            lable.textColor = LSTitleGrayColor3; lable.sd_layout.leftEqualToView(self.contentView).centerYEqualToView(self.contentView).widthIs(width).heightIs(30);
        }else if (i==1){
            self.logoImage = [[UIImageView alloc] init];
            [self.contentView addSubview:self.logoImage];
            self.logoImage.sd_layout.leftEqualToView(self.contentView).offset(width).centerYEqualToView(self.contentView).widthIs(20).heightIs(20);
            
            
            lable.sd_layout.leftSpaceToView(self.logoImage, 0).centerYEqualToView(self.contentView).widthIs(80).heightIs(30);
            lable.textAlignment = NSTextAlignmentCenter;
            
        }else{
            lable.sd_layout.leftEqualToView(self.contentView).offset(width+95+(i-2)*width).centerYEqualToView(self.contentView).widthIs(width).heightIs(30);
        }
    }
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = LSLineGrayColor;
    [self.contentView addSubview:lineView];
    lineView.sd_layout.leftEqualToView(self.contentView).bottomEqualToView(self.contentView).rightEqualToView(self.contentView).heightIs(0.5);
}
- (void)setModel:(LSLeagueSizeplateModel *)model{
    _model = model;
    NSArray *array = @[model.ranking,model.TeamName,model.MatchTotol,model.MaxBall,model.Flat,model.MinBall,model.MaxBallProbability,model.FlatProbability,model.MinBallProbability];
    [self.lableArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *lable = (UILabel *)obj;
        lable.text = array[idx];
    }];
    
    [self.logoImage sd_setImageWithURL:[NSURL URLWithString:TeamImageHeaderUrl((long)model.TeamId)] placeholderImage:nil];
    
}
- (NSMutableArray *)lableArray{
    if (!_lableArray) {
        _lableArray = [NSMutableArray array];
        
    }
    return _lableArray;
}
@end


#pragma mark 🔥 LSLeagueFixtruesCell
@interface LSLeagueFixtruesCell()
@property (nonatomic,strong) UILabel *timelable;
@property (nonatomic,strong) UILabel *homeTeam;
@property (nonatomic,strong) UILabel *scorelable;
@property (nonatomic,strong) UILabel *guestTeam;
@end
@implementation LSLeagueFixtruesCell

+(LSLeagueFixtruesCell *)FixtruesCellByTableView:(UITableView *)tableView{
    LSLeagueFixtruesCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSLeagueFixtruesCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }return cell;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
//    self.timelable.text = @"2017/11/04 08:30";
    [self.contentView addSubview:self.timelable];
    self.timelable.sd_layout
    .leftEqualToView(self.contentView).offset(LSAutoVlaue(10, LSScreenWidth))
    .centerYEqualToView(self.contentView)
    .widthIs(LSAutoVlaue(110, LSScreenWidth))
    .heightIs(LSAutoVlaue(35, LSScreenHeight));
    
//    self.homeTeam.text = @"巴萨罗那";
    [self.contentView addSubview:self.homeTeam];
    self.homeTeam.sd_layout
    .leftSpaceToView(self.timelable, LSAutoVlaue(10, LSScreenWidth))
    .centerYEqualToView(self.contentView)
    .widthIs(LSAutoVlaue(80, LSScreenWidth))
    .heightIs(LSAutoVlaue(35, LSScreenHeight));
    
    self.scorelable.text = @"1:1";
    [self.contentView addSubview:self.scorelable];
    self.scorelable.sd_layout
    .leftSpaceToView(self.homeTeam, LSAutoVlaue(10, LSScreenWidth))
    .centerYEqualToView(self.contentView)
    .widthIs(LSAutoVlaue(30, LSScreenWidth))
    .heightIs(LSAutoVlaue(35, LSScreenWidth));
    
//    self.guestTeam.text = @"皇家马德里";
    [self.contentView addSubview:self.guestTeam];
    self.guestTeam.sd_layout
    .leftSpaceToView(self.scorelable, LSAutoVlaue(10, LSScreenWidth))
    .centerYEqualToView(self.contentView)
    .widthIs(LSAutoVlaue(80, LSScreenWidth))
    .heightIs(LSAutoVlaue(35, LSScreenHeight));
    
}
- (NSString *)getTimeStrWithStr:(NSString *)timeStr{
    
    NSString * timeStr1 = [timeStr componentsSeparatedByString:@"T"].lastObject;
    NSArray * array1 = [timeStr1 componentsSeparatedByString:@":"];
    NSMutableArray * array2 = [NSMutableArray arrayWithArray:array1];
    [array2 removeLastObject];
    NSString * str = [array2 componentsJoinedByString:@":"];
    return str;
}
- (void)setModel:(LSLeagueFixtruesModel *)model{
    _model = model;
    self.homeTeam.text = model.HomeTeamName;
    self.guestTeam.text = model.GuestTeamName;
    self.timelable.text = [self getTimeStrWithStr:model.MatchStartTime];
    self.scorelable.text = model.TeamScore;
}
- (UILabel *)timelable{
    if (!_timelable) {
        _timelable = [[UILabel alloc] init];
        _timelable.textAlignment = NSTextAlignmentCenter;
        _timelable.textColor = LSTitleGrayColor2;
        _timelable.font = LSFontSize(13,LSScreenWidth);
    }
    return _timelable;
}
- (UILabel *)homeTeam{
    if (!_homeTeam) {
        _homeTeam = [[UILabel alloc] init];
        _homeTeam.textAlignment = NSTextAlignmentCenter;
        _homeTeam.textColor = LSTitleGrayColor2;
        _homeTeam.font = LSFontSize(13,LSScreenWidth);
    }
    return _homeTeam;
}
- (UILabel *)scorelable{
    if (!_scorelable) {
        _scorelable = [[UILabel alloc] init];
        _scorelable.textAlignment = NSTextAlignmentCenter;
        _scorelable.textColor = LSTitleGrayColor2;
        _scorelable.font = LSFontSize(13,LSScreenWidth);
    }
    return _scorelable;
}
- (UILabel *)guestTeam{
    if (!_guestTeam) {
        _guestTeam = [[UILabel alloc] init];
        _guestTeam.textAlignment = NSTextAlignmentCenter;
        _guestTeam.textColor = LSTitleGrayColor2;
        _guestTeam.font = LSFontSize(13,LSScreenWidth);
    }
    return _guestTeam;
}
@end


